﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
using System.Windows.Forms;

namespace ICeFramework.Win.UI.Util
{
    public static class WindowsFormsUtils
    {
        public static bool SafeCompareStrings(string string1, string string2, bool ignoreCase)
        {
            if ((string1 == null) || (string2 == null))
            {
                return false;
            }
            if (string1.Length != string2.Length)
            {
                return false;
            }
            return (string.Compare(string1, string2, ignoreCase, CultureInfo.InvariantCulture) == 0);
        }

        internal static Form GetForm(this Control control)
        {
            Control c = control.Parent;
            while (c != null && c as Form != null)
            {
                c = c.Parent;
            }
            return c as Form;
        }

    }
}
